package com.bwie.shop.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bwie.shop.entity.MiddleEntity;
import com.bwie.shop.service.MiddleService;
import com.bwie.common.utils.PageUtils;
import com.bwie.common.utils.R;



/**
 * 
 *
 * @author shop
 * @email sunlightcs@gmail.com
 * @date 2022-06-19 15:32:35
 */
@RestController
@RequestMapping("shop/middle")
public class MiddleController {
    @Autowired
    private MiddleService middleService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = middleService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{middleId}")
    public R info(@PathVariable("middleId") Integer middleId){
		MiddleEntity middle = middleService.getById(middleId);

        return R.ok().put("middle", middle);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody MiddleEntity middle){
		middleService.save(middle);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody MiddleEntity middle){
		middleService.updateById(middle);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] middleIds){
		middleService.removeByIds(Arrays.asList(middleIds));

        return R.ok();
    }

}
